package persistance;

import java.util.*;

public class Protocols 
{

	public Protocols(String filename, ArrayList<Message> messagelist)
	{
		set_filename(filename);
		set_messageList(messagelist);
		
		System.out.println("\nCREATED MESSAGELIST FOR FILE: " + get_filename() + "\n");
	}
	
	private String _filename;
	private ArrayList<Message> _messageList;

	
	public String get_filename() 
	{
		return _filename;
	}
	public void set_filename(String _filename) 
	{
		this._filename = _filename;
	}
	public ArrayList<Message> get_messageList() 
	{
		return _messageList;
	}
	public void set_messageList(ArrayList<Message> list) 
	{
		_messageList = list;
	}
	
	//print the list of messages
	public void print_theMessageList()
	{
		Iterator iterator = _messageList.iterator();
		
		System.out.println("LIST OF MESSAGES:");
		
		while(iterator.hasNext())
		{
			Object o = iterator.next();
			if(o instanceof Message)
			{
				Message m = (Message)o;
				System.out.println("MESSAGE: " + m.get_name() + " | TYPE: " + m.get_type() + " | FROM: " + m.get_parent() + " | TO: " + m.get_child());		
			}							
		}	
		System.out.println();
	}
}
